package com.vlong.town.controller.server.suggestion;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.vlong.town.controller.base.BaseController;
import com.vlong.town.entity.base.DataMessage;
import com.vlong.town.service.suggestion.SuggestionService;
import com.vlong.town.util.common.TownConstant;
/**
 * 问题反馈Rest接口Controller
 * @author Assassin
 */
@RequestMapping("/rest/suggestion")
@RestController
public class SuggestionRestController extends BaseController{

	@Autowired
	private SuggestionService suggestionService;// 问题反馈业务实现
	
	@ResponseBody
	@PostMapping("/addSuggestion")
	public  DataMessage  addSuggestion(
    		@RequestParam(required=true, value="wxId") String wxId,
    		@RequestParam(required=true, value="title") String title,
    		@RequestParam(required=true, value="content") String content
			){
		DataMessage  dm=new  DataMessage();	
		if(!validateStringProperty(title, 1, 128)){
    		dm.setResult(TownConstant.RESULT_CODE_DATA_ERROR);
    		dm.setMessage("反馈标题参数错误");
    	}else  if(!validateStringProperty(wxId, 1, 128)){
    		dm.setResult(TownConstant.RESULT_CODE_DATA_ERROR);
    		dm.setMessage("微信id参数错误");
    	}else  if(!validateStringProperty(content, 2, 128)){
    		dm.setResult(TownConstant.RESULT_CODE_DATA_ERROR);
    		dm.setMessage("反馈内容参数错误");
    	}else{
    		suggestionService.add(null, 1, title, null, content, null, null, null, null, null, 2, null, null, null, System.currentTimeMillis(), null);
    		dm.setResult(TownConstant.RESULT_CODE_SUCCESS);
    		dm.setMessage("反馈成功");
    	}
		return  dm;
	}
	
}
